var backgroundAudioManager;
module.exports = (options) => {
  return new Promise((resolve, reject) => {
    if (backgroundAudioManager) {
      backgroundAudioManager.stop();
      return setTimeout(() => {
        backgroundAudioManager = wx.createInnerAudioContext();
        backgroundAudioManager.autoplay = options.autoplay || true;
        backgroundAudioManager.startTime = options.startTime || 0;
        backgroundAudioManager.obeyMuteSwitch = options.obeyMuteSwitch || false;
        backgroundAudioManager.src = options.src;
        // return backgroundAudioManager;
        return resolve(backgroundAudioManager);
      }, 50)

    } else {
      backgroundAudioManager = wx.createInnerAudioContext();
      backgroundAudioManager.autoplay = options.autoplay || true;
      backgroundAudioManager.startTime = options.startTime || 0;
      backgroundAudioManager.obeyMuteSwitch = options.obeyMuteSwitch || false;
      backgroundAudioManager.src = options.src;
      // return backgroundAudioManager;
      return resolve(backgroundAudioManager);
    }


    //  onPlay:()=>{

    //  }
    //  onPlay: () => {

    //  }
    //  onEnded: () => {

    //  }
    //  onStop: () => {

    //  }
    //  onError: () => {

    //  }
    //  onWaiting: () => {

    //  }
  })
}